#include"slist.h"
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct ListNode* addTwoNumbers(SListNode* l1, SListNode* l2) {
    int sum1 = 0;
    int sum2 = 0;
    int k = 0;
    struct ListNode* l3phead = NULL;
    while (l1)
    {
        sum1 = sum1 + l1->val * (int)pow(10, k);
        l1 = l1->next;
        k++;
    }
    k = 0;
    while (l2)
    {
        sum2 = sum2 + l2->val * (int)pow(10, k);
        l2 = l2->next;
        k++;
    }
    int sum3 = sum1 + sum2;
    while (k)
    {
        SListNode* newnode = (SListNode*)malloc(sizeof(SListNode));
        if (newnode == NULL)
        {
            perror("malloc failed");
            exit(-1);
        }
        newnode->next = NULL;
        int num3 = sum3 % (int)pow(10, k);
        newnode->val = num3;
        if (l3phead == NULL)
        {
            newnode = l3phead;
        }
        else
        {
            SListNode* cur = l3phead;
            while (cur->next)
            {
                cur = cur->next;
            }
            cur->next = newnode;
        }
        k--;
    }
    return l3phead;
}
void Test1()
{
	SListNode* plist = NULL;
	//PushBack(&plist, 1);
	//PushBack(&plist, 2);
	//PushBack(&plist, 3);
	//PushBack(&plist, 4);
	PushFront(&plist, 704);
	SListNode* pos = SListFind(plist, 704);
	printf("%d\n", pos->a);
	SListPushPos(pos, 715);
	SListErease(&plist, pos);
	SListPrint(plist);
	SListDestroy(&plist);
}
void Test2()
{
	SListNode* l2 = NULL, * l1 = NULL;
	PushBack(l1, 2);
	PushBack(l1, 4);
	PushBack(l1, 3);
	PushBack(l2, 5);
	PushBack(l2, 6);
	PushBack(l2, 4);
}
int main()
{
	Test2();
	return 0;
}